<!doctype html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<!--<link href="css/list.css" rel="stylesheet" />-->
		<script src="../../js/mui.min.js"></script>
		 <script src="../../js/app.js"></script>
		 <!--<link href="css/style.css" rel="stylesheet" />-->
		 <link href="../../css/mui.min.css" rel="stylesheet" />
		 <link href="../../css/mui.picker.css" rel="stylesheet"/>
        <link href="../../css/mui.poppicker.css" rel="stylesheet" />
		 		<style type="text/css">
</style>
</head>
<body>
	<header class="mui-bar mui-bar-nav">
	    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
	    <h1 class="mui-title">项目发布</h1>
	</header>
	<div id="crop_result" style="display:none;text-align: center;width: 100%; padding-top: 30px; height: 230px; line-height: 300px;"><span><img id="headimg" style="display:block;margin: 0 auto" src="" alt="" /></span></div>
<div class="mui-content" style="display:block;">
    <form class="mui-input-group" name="myform">
      	    <div class="mui-input-row">
      	        <label>标题名称</label>
      	        <input type="text" id="name" class="mui-input-clear" placeholder="请输入标题(不超过10字)">
      	    </div>
      	    <!--<div class="mui-input-row">
      	        <label>生日</label>
      	        <input type="text"  id='birthday' onclick="datarow(this)" class="mui-input-clear" placeholder="2019-12-20"style="float:left;width: 30%;" placeholder="1000"><label style="float: left;width: 90px;padding-left: 0;">日</label>
      	    </div>-->
      	    <div class="mui-input-row" id='showCityPicker'>
      	        <label >地区</label>
      	        <input style="width:100px" id="city" type="button" value=""><input style="width:100px" id="province" type="button" value="请选择">
      	    </div>
      	    <!--<div class="mui-input-row">
      	        <label>性别</label>
				   <select id="sex"style="width:65%;">
				  <option value="男">男</option>
				  <option value="女">女</option>
				 </select> 
      	    </div>-->
      	    <div class="mui-input-row">
      	        <label>类型范围</label>
		  	 	<select id="world"style="width:65%;">
			 	</select> 
      	    </div>
			<!--<div class="mui-input-row">
      	        <label>特长</label>
      	        <input type="text" id="speciality" class="mui-input-clear" placeholder="(不超过30字)民族舞,吉他,摄影,融资" >
      	    </div>-->
      	    <!--<div class="mui-input-row">
      	        <label>代表作品<span style="font-size: 0.5em;"></span></label></div>
      	        <textarea type="text" id="opus"  class="mui-input-clear"  maxlength="200" type="text" rows="3" cols="30" placeholder="(不超过100字)电影《战狼2》-担任：摄影师,电视剧《武媚娘》-饰演：媚娘" ></textarea>-->
      	    <!--<div class="mui-input-row">
      	        <label>提供资源</label>
      	        <input type="text" id="resource" class="mui-input-clear" placeholder="(不超过50字)品牌赞助,明星对接,融资,发行推荐" >
      	    </div>-->
      	    <div class="mui-input-row">
      	        <label>所属公司</label>
      	        <input type="text" id="company"  class="mui-input-clear" placeholder="北京大唐圣殿影视文化有限公司" >
      	    </div>
      	    <ul class="mui-table-view">
			        <li class="mui-table-view-cell mui-collapse"><a class="mui-navigate-right" href="#">
						<span>主图</span><span class="mui-badge mui-badge-primary">上传</span>
					</a>
					<ul class="mui-table-view">
						 <div class="mui-table-view-cell" id="image"  onclick="image()" style="max-width:99%;text-align:center;">添加
			    <img  style="margin: 1% 8%;width: 80%;height: auto;"   src="" />
			</div>
			</ul>
        </li></ul>
      	    <ul class="mui-table-view" >
			        <li class="mui-table-view-cell mui-collapse"><a class="mui-navigate-right" href="#">
						<label>支持合作方式</label><span class="mui-badge mui-badge-primary">多选</span>
					</a>
					<ul class="mui-table-view">
						<li class="mui-table-view-cell" id="ways">
						<div style="width: 49%;float: left;"></div>
					    </li>
      </ul>
        </li></ul>
      	   


      	    <div class="mui-input-row">
      	        <label>简介</label></div>
      	        <textarea id="synopsis"  class="mui-input-clear" placeholder="请输入不超过200字简介" maxlength="200" type="text" rows="3" cols="30"></textarea>

      	</form> 
      	<!--<div class="mui-input-row">-->
<!--<div id="allmap"></div>-->
      	<button type="button" class="mui-btn mui-btn-blue" style="padding:7px;margin: 1%;width: 98%;font-size: 18;" onclick="tijiao()">提交</button>
      	<!--</div>-->
      </div>
      <!--<div>查看数据详单>>>></div>-->
</body>
    <script src="../../js/mui.picker.js"></script>
    <script src="../../js/mui.poppicker.js"></script>
    <script src="../../js/city.data.js"></script>
    <script src="../json/world.js"></script>
    <!--<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=uQVFuWg9jXT1b5iiruT03ZcpPlZRlNCd"></script>-->
    <!--<script type="text/javascript" src="http://api.map.baidu.com/api?v=3.0&ak=uQVFuWg9jXT1b5iiruT03ZcpPlZRlNCd"></script>-->
    <!--<script type="text/javascript" src="http://developer.baidu.com/map/jsdemo/demo/convertor.js"></script>-->
<script type="text/javascript">	
//alert(JSON.stringify(world));
function translatePoint(position){  
    var currentLon = position.coords.longitude;  
    var currentLat = position.coords.latitude;  
    var gpsPoint = new BMap.Point(currentLon,currentLat);  
    BMap.Convertor.translate(gpsPoint,2,initMap); //坐标转换  
}  
function initMap(point){  
    map = new BMap.Map("mapDiv"); //创建地图  
    map.addControl(new BMap.NavigationControl());  
    map.addControl(new BMap.ScaleControl());  
    map.addControl(new BMap.OverviewMapControl());  
    map.centerAndZoom(point,15);  
    map.addOverlay(new BMap.Marker(point));  
    
}  
mui.plusReady(function() {  
                plus.geolocation.getCurrentPosition(translatePoint,function(e){  
                    mui.toast("异常:" + e.message);  
       });  
});  
////当前位置  
//function translatePoint(position){  
//  currentLon = position.coords.longitude;  
//  currentLat= position.coords.latitude;  
//  console.log("当前位置："+currentLon +","+currentLat);  
//}  


	(function($, doc) {
		$.init();
		$.ready(function() {
			var cityPicker = new $.PopPicker({
				layer: 2
			});
			cityPicker.setData(cityData);
			var showCityPickerButton = doc.getElementById('showCityPicker');
//			var cityResult = doc.getElementById('cityResult');
			showCityPickerButton.addEventListener('tap', function(event) {
				doc.getElementById('province').value='请选择';
					doc.getElementById('city').value='';
				cityPicker.show(function(items) {
					doc.getElementById('province').value=items[0].text;
					doc.getElementById('city').value=items[1].text;
//					cityResult.innerText = "你选择的城市是:" + items[0].text + " " + items[1].text;
					//返回 false 可以阻止选择框的关闭
					//return false;
				});
			}, false);
		})
	})(mui, document);
//调用方式
	window.addEventListener('renovate', function(e){
		//裁剪后返回的64base图片显示在image标签下的img
		document.getElementById('image').getElementsByTagName('img')[0].src=e.detail.image;
				//主图裁剪上传返回数据执行更新
//			  location.reload(); //刷新
			  });
	function image() {
		act='resource';
		method='resource';
		width=300;
		height=300;
		localStorage.image='{"tid":"'+tid+'","act":"up'+act+'","method":"'+method+'","src":"","width":'+width+',"height":'+height+'}';
		mui.openWindow('../../Plugin/image/base64.html');
	};
var optbJson={
//		"xiangmuleixing":{"院线电影":"院线电影","网络电影":"网络电影","电视剧":"电视剧","网络剧":"网络剧"},
		"ways":{"资源入股":"资源入股","技术入股":"技术入股","带资入股":"带资入股","部分入股":"部分入股","现金结算":"现金结算","其他":"其他"},
		"world":world
//		"ziyuanleibie":{"器材":"器材","车辆":"车辆","机房":"机房","产品":"产品","影棚":"影棚","场景":"场景","住宿":"住宿","餐饮":"餐饮","其他":"其他"}
		 };
		 
for(var k in optbJson){
var rugufangshiche='';
var	obj = document.getElementById(k);
//	alert(k+optbJson[k]);
for(var p in optbJson[k]){//遍历json对象的每个key/value对,p为key
if(k=='world'){
rugufangshiche+='<option name="'+k+'" value="'+p+'">'+optbJson[k][p]+'</option>';	
}else{
rugufangshiche+='<div style="width: 49%;float: left;"><input name="'+k+'" value="'+p+'" type="checkbox" checked><label>'+optbJson[k][p]+'</label></div>';
}
}
obj.innerHTML=rugufangshiche;
}
function tijiao(){
	var sizenum=1;
	if(document.getElementById('synopsis').value.length<sizenum){
		alert('简介最少需要'+sizenum+'字，请从新提交');
//		return false;
	}
	// 得到页面中所有input	
	var allInputs = document.getElementsByTagName('input');
	var libIds = [];
	// 在所有Input中过滤出type="text" and name="libID"的元素，放到数组libIds中  && allInputs[i].name === 'libname'
//	for (var i = 0; i < allInputs.length; i++) {
//		if (allInputs[i].type === 'text' && allInputs[i].name === 'libname') 
//		{
//			libIds.push(allInputs[i]);	
//			if(allInputs[i].value==''){
//			alert('您有表单未填写，请填写后提交');
////			return false;
//			}
//		}
//	}
			ways_val='';
	for(var kb in optbJson){
			var	objtj = document.getElementsByName(kb);
//  		alert(kb);
	    for(pb in objtj){
	        if(objtj[pb].checked){
	    	if(kb=='ways'){ways_val+=objtj[pb].value+',';};
	    }
    }}
//	var birthday_val = new Date(document.getElementById('birthday').value.replace(/-/g,'/'))/1000;

mui.post(home.hos+'/resource/admin',Object.assign(apptoken,{
		act:'publish',
		name:document.getElementById('name').value,
		world:document.getElementById('world').value,
//		speciality:document.getElementById('speciality').value,
//		birthday:birthday_val,
		ways:ways_val,
//		sex:document.getElementById('sex').value,
		synopsis:document.getElementById('synopsis').value,
//		opus:document.getElementById('opus').value,
//		resource:document.getElementById('resource').value,
		province:document.getElementById('province').value,//省级
		city:document.getElementById('city').value,//城市
		company:document.getElementById('company').value,//公司
		image:document.getElementById('image').getElementsByTagName("img")[0].src
	}),function(data){
		alert(data);
		if(data!=200){
			plus.ui.toast("发布失败,请重新尝试，错误码".data);
		}else{
				alert("发布成功");
				mui.back();
				var list = plus.webview.currentWebview().opener();
				//触发父页面的自定义事件(refresh),从而进行刷新
				 mui.fire(list, 'refresh');
				//返回true,继续页面关闭逻辑
				return true;
				}
		//服务器返回响应，根据响应结果，分析是否登录成功；

	},'text'
);}
function datarow(data){
	var dDate = new Date();
    //设置当前日期（不设置默认当前日期）
    dDate.setFullYear(2018, 7, 16);
    var minDate = new Date();
    //最小时间
    minDate.setFullYear(2018, 0, 1);
    var maxDate = new Date();
    //最大时间
    maxDate.setFullYear(2035, 11, 31);
    plus.nativeUI.pickDate(function(e) {
        var d = e.date;
        document.getElementById(data.id).value=d.getFullYear()+ "-" + (d.getMonth() + 1) + "-" + d.getDate();
        mui.toast('您选择的日期是:' + d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate());
    }, function(e) {
        mui.toast("您没有选择日期");
    }, {
        title: '请选择日期',
        date: dDate,
        minDate: minDate,
        maxDate: maxDate
    });
	
}

//function Show_Hidden(trid){
//  if(trid.style.display=="block"){
//      trid.style.display='none';
//  }else{
//      trid.style.display='block';
//  }
//}


  </script>